package com.xing.oss.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

/**
 * 常量属性工具类
 *
 * @author: xingfuhao
 * @create: 2022-01-17 23:36
 */

//当项目一启动，Spring接口，Spring加载之后，执行接口的一个方法
@Configurable//交给Spring管理
public class ConstantPropertiesUtils implements InitializingBean {

    //读取配置文件
    @Value("${aliyun.oss.file.endpoint}")
    private String endPoint;

    @Value("${aliyun.oss.file.keyid}")
    private String keyId;

    @Value("${aliyun.oss.file.keysecret}")
    private String keySecret;

    @Value("${aliyun.oss.file.bucketname}")
    private String bucketName;

    //定义公开静态常量
    public static  String END_POIND;
    public static  String ACCEASS_KEY_ID;
    public static  String ACCESS_KEY_SECRET;
    public static  String BUCKET_NAME;
    @Override
    public void afterPropertiesSet() throws Exception {
        END_POIND=endPoint;
        ACCEASS_KEY_ID=keyId;
        ACCESS_KEY_SECRET=keySecret;
        BUCKET_NAME=bucketName;
    }
}
